Skip to content

Conversation

@staabm
Copy link
Contributor

@staabm staabm commented Jan 20, 2026

closes phpstan/phpstan#13985
closes phpstan/phpstan#14046

partly reverts #4761

@ondrejmirtes
Copy link
Member

I don't get it, why shouldn't it be cached?

@staabm
Copy link
Contributor Author

staabm commented Jan 20, 2026

ClassReflection created via withTypes has properties like isDeprecated, isGeneric, isInternal set to null

grafik

while the one created via getClass contains more information:

grafik

so by caching the withTypes created one, we have less information at hand later on when we respond to a getClassReflection() call with a cached object

@staabm
Copy link
Contributor Author

staabm commented Jan 20, 2026

Hmm no. This doesn't make sense. Will have another look tomorrow

@staabm
Copy link
Contributor Author

staabm commented Jan 21, 2026

had another look but still I am not yet sure about the causation.

the difference between caching and not caching is, that

  • when caching generics ClassReflection for SplObjectStorage the template-type map will be ErrorType, ErrorType which causes lots of if instanceof ErrorType logic to happen and fallbacks are getting evaluated
  • when not caching generics ClassReflection for SplObjectStorage the template-type map will reflect the unresolved types of the phpdoc stub

Copy link
Contributor

@cs278 cs278 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested - fixes phpstan/phpstan#14046 for me

@staabm staabm force-pushed the bug13985 branch 3 times, most recently from ef0b40d to b32a638 Compare February 6, 2026 07:38
@staabm staabm merged commit d298e69 into phpstan:2.1.x Feb 9, 2026
661 of 668 checks passed
@staabm staabm deleted the bug13985 branch February 9, 2026 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DatePeriod iterator types no longer understood Errors related to SplObjectStorage in 2.1.34

4 participants